<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>HOME</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../css/app.css" />
		<style type="text/css">
			#select {
				color: #E2E2E4;
			}
			#mainbottom {
				background-color: #f8f8fa;
				padding-bottom: 10px;
			}
			#mainbottom li {
				height: 40px;
				background-size: 80% auto;
				background-repeat: no-repeat;
				background-position: center center;
			}
			#tongji {
				background: url(../image/tongji.png);
			}
			#wrong {
				background: url(../image/cuoti.png);
			}
			#history {
				background: url(../image/history.png);
			}
		</style>
	</head>

	<body>
		<div class="mui-content">
			<div style="padding:11px 16px;border-bottom: 2px solid #30A4ED;">
				<h4 class="mui-text-center" id="select"><span id="cname" style="color: #070707;">选择科目</span> <span class="mui-icon mui-icon-arrowdown"></span></h4></div>
			<div class="main-nav">

				<ul class="mui-table-view mui-grid-view mui-grid-9" style="background-color: #f8f8fa;">

					<li class="mui-table-view-cell mui-media mui-col-xs-6" id="practise">
						<div class="grid-img">
							<a href="#">
								<img src="../image/main/linianzhenti.png" />
							</a>
						</div>
					</li>
					<li class="mui-table-view-cell mui-media mui-col-xs-6" id="suiji">
						<div class="grid-img">
							<a href="#">
								<img src="../image/main/suijilianxi.png" />
							</a>
						</div>
					</li>
					<li class="mui-table-view-cell mui-media mui-col-xs-6">
						<div class="grid-img">
							<a href="#" id="jiangyi">
								<img src="../image/main/dagangjiangyi.png" />
							</a>
						</div>

					</li>
					<li class="mui-table-view-cell mui-media mui-col-xs-6">
						<div class="grid-img">
							<a id="ketang">
								<img src="../image/main/zaixianketang.png" />
								<!--<img src="../image/main/zhangjielianxi.png" />-->
							</a>
						</div>
					</li>
				</ul>
				<ul class="mui-table-view mui-grid-view mui-grid-9" id="mainbottom">
					<li class="mui-table-view-cell mui-media mui-col-xs-4" id="tongji">
					</li>
					<li class="mui-table-view-cell mui-media mui-col-xs-4" id="wrong">
					</li>
					<li class="mui-table-view-cell mui-media mui-col-xs-4" id="history">
					</li>

				</ul>
			</div>
		</div>
	</body>
	<script src="../script/db.js" type="text/javascript" charset="utf-8"></script>
	<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../script/app.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		apiready = function() {
			var cid = localStorage.getItem('cid');
			var system = api.systemType;
			if (cid) {
				var cname = localStorage.getItem('cname');
				document.getElementById("cname").innerHTML = cname;
			} else {
				api.openWin({
					name: 'selectcate',
					url: 'selectcate.html'
				});
			}
			//			var func = function(db) {
			//				var sql = 'SELECT * from version';
			//				db.selectSql({
			//					name: 'data',
			//					sql: sql
			//				}, function(ret, err) {
			//					if (ret.status) {
			////						alert(JSON.stringify(ret.data));
			//					} else {
			//						var fs = api.require('fs');
			//						fs.remove({
			//							path: 'fs://res/data.db'
			//						}, function(ret, err) {
			//							var status = ret.status;
			//							if (status) {
			//								APP.openDb;
			//							} else {
			//								api.alert({
			//									msg: err.msg
			//								});
			//							}
			//						});
			//					}
			//				});
			//			}
			//			APP.openDb(func);//打开题目数据库
			document.getElementById("practise").addEventListener('tap', function() {
				api.openWin({
					name: 'testlist',
					url: 'testlist.html',
					pageParam: {
						type: "free"
					}
				});
			});
			document.getElementById("suiji").addEventListener('tap', function() {
				var cid = localStorage.getItem('cid');
				var target = 'course-'+cid;
				api.openWin({
					name: 'practise',
					url: 'practise.html',
					pageParam: {
						type: "random",
						target:target
					}
				});
			});
			document.getElementById("jiangyi").addEventListener('tap', function() {
				api.openWin({
					name: 'teachnotes',
					url: 'teachnotes.html'
				});
			});
			document.getElementById("select").addEventListener('tap', function() {
				api.openWin({
					name: 'selectcate',
					url: 'selectcate.html'
				});
			});
			document.getElementById("tongji").addEventListener('tap', function() {
				api.openWin({
					name: 'analysis',
					url: 'analytic.html'
				});
			});
			document.getElementById("history").addEventListener('tap', function() {
				api.openWin({
					name: 'history',
					url: 'history.html'
				});
			});
			document.getElementById("wrong").addEventListener('tap', function() {
				if (getUserKey()) {
					api.openWin({
						name: 'wrong',
						url: 'wrong.html'
					});
				} else {
					login();
				}
			});
			document.getElementById("ketang").addEventListener('tap', function() {
				if(system=="ios"){
					api.openWin({
						name: 'practiselist',
						url: 'practiselist.html'
					});
				}else{
					api.openWin({
						name: 'win',
						url: 'win.html',
						pageParam: {
							url: "http://wangxiao.ruiyinedu.com/",
							purl:"http://wangxiao.ruiyinedu.com/",
							title:"在线课堂"
						}
					});
				}
				
			});
			api.addEventListener({
				name: 'courseSelected'
			}, function(ret, err) {
				if (ret && ret.value) {
					var value = ret.value;
					document.getElementById("cname").innerHTML = value.cname;
				}
			});
		}
	</script>

</html>